<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML>
<html>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
	<title>订单确认</title>
	<link rel="stylesheet" href="../css/commodity.css">
	<link rel="stylesheet" href="../css/demo.css">
	<link rel="stylesheet"  href="../css/component.css">
	<link rel="stylesheet" href="../css/content.css">
	<link rel="stylesheet" href="../css/pay.css">
	<link rel="stylesheet" href="../css/shoppingCart.css">
</head>
<body>
	<div class="wrap">
		<div class="logo">
		<!--头部-->
			<a href=""><img src="../images/dota2_logn.png" alt="恋尚优饰品交易中心"></a>
			<div class="login">
						<div class="user">
							<div class="user_img">
								<img src="../images/user.png" alt="" />
							</div>
							<div class="user_name" onmouseover="$('#user_name_none').css('display', 'block');"
								onmouseout="$('#user_name_none').css('display', 'none');">
								<a href="" id="user_name_a">
									<span>${userInfo. uName}</span> <b class="caret"></b>
								</a>
								<ul id="user_name_none">
									<li class="user_home"><a
										href="userCenter">个人主页</a></li>
									<li class="out_login"><a href="javascript:void(0)"
										id="quit"   onclick="loginOut()">退出登录</a></li>
								</ul>
							</div>
						</div>
			<!-- end -->
			</div>
		</div>
		<!--头部end-->
		<div class="bodyer">
			<div class="container">
			<!--主体内容-->
			<div class="site">
			<!-- 位置 -->
				<div class="home_icon">
						<a href=""><img src="../images/home_icon.png" alt=""></a>
					</div>
					<div class="triangle"></div>
					<div class="site_sp">
						<a href="">饰品市场</a>
					</div>
					<div class="triangle1"></div>
					<div class="site_ss">
						商家发货
					</div>
			<!-- 位置end -->
			</div>
			<div class="cart">
				<div class="cart_bg">
						<h3>订单确认 </h3>
						<h4> Order payment
						</h4>
						<div class="step_pull">
							<div class="step1">
								<div class="num ">1</div>
								<div class="txt">购物车订单</div>
							</div>
							<div class="step_line"></div>
							<div class="step_line2"></div>
							<div class="step2">
								<div class="num">2</div>
								<div class="txt">订单确认</div>
							</div>
							<div class="step_line"></div>
							<div class="step_line2"></div>
							<div class="step2">
								<div class="num curr">3</div>
								<div class="txt curr1">商家发货</div>
							</div>
							<div class="step_line_curr"></div>
							<div class="step_line2"></div>
							<div class="step2">
								<div class="num">4</div>
								<div class="txt">交易成功</div>
							</div>
						</div>
					</div>
					<div class="site"><div class="site_ss" style="color: #ee4e10;">&nbsp;&nbsp;&nbsp;订单成功提示	</div></div>
				
				<div class="pay_bottom">
					<div class="pay_text">
					订单提交成功，等待商家发货。。。
					</div>
				</div>
					</div>
			</div>
		</div>
		<div class="footer">
			<div class="footer_container">
				<p>
					<a href="index.html">首页</a><b>|</b>
					<a href="">关于我们</a><b>|</b>
					<a href="">意见反馈</a><b>|</b>
					<a href="">商务合作</a>
				</p>
			</div>
		</div>
		<div class="nav">
			<div class="shopper">
				<a href="shopping">
					<span><img src="../images/shopper.png" alt=""></span>
					<div class="shopper_gw">购物车</div>
				</a>
					<div class="shopper_nums"></div>
				<div class="shopper_most">
					<img src="../images/top.png" alt="">
				</div>
			</div>
		</div>
	</div>
	<div id="address-div" >
			<div class="addr">
					<div class="addr-header">创建地址<a href="javascript:void(0)" title="关闭" class="tc-popup-hide" " >关闭</a></div>
					<div class="addr-content">
							<div class="item">
									<span class="tsl">新增收货地址　</span>
									<span>电话号码、手机号选填一项, 其余均为必填项</span>
							</div>
							<div class="item">
								<span>所在地区<label class="tsl"> *</label></span>
								<div>
									<select id="selProvince" name="code" class="first-select" onchange="getRegionProvince()">
									  <option value ="1"  selected="selected" >中国</option>
									  <option value="0">海外其他</option>
									</select>
								</div>
								<div>
									<select  id="selCity" name="code" class="first-select" onchange="getSupportCityDataset()">
									
									</select>
								</div>
								<div id="yesOrNo">
									<select id="selShi"  name="code"  class="first-select">
									
									</select>
								</div>
						
							</div>
							<div class="item">
								<span>详细地址<label class="tsl"> *</label></span>
								<div>
									<textarea id="addrTextarea" style="height: 60px;width: 400px;"></textarea>
								</div>
							</div>
							<div class="item">
								<span>邮政编码</span>
								<div><input name="zipCode" type="text" style="width:200px; "/></div>
							</div>
							<div class="item">
								<span>收货人姓名<label class="tsl"> *</label></span>
								<div><input name="riName" type="text" style="width:200px; "/></div>
							</div>
							<div class="item">
								<span>手机号码</span>
								<div>
									<select id="selPhone" class="first-select">
									  <option value ="0">中国大陆</option>
									  <option value="1">海外其他</option>
									</select>
								</div>
								<div><input name="phone" type="text" style="width:200px; "/></div>
							</div>
							<div class="item">
								<span>电话号码</span>
								<div>
									<select id="selTel" class="first-select" >
									  <option value ="0" selected="selected">中国大陆</option>
									  <option value="1">海外其他</option>
									</select>
								</div>
								<div><input name="tel" type="text" style="width:200px; "/></div>
							</div>
							<div class="item"><span></span><button type="button" class=" btn  tsl" id="addr_saveSubmit">保存</button></div>
					</div>
			</div>
	
	</div>
	<script src="../js/jquery-1.js"></script>
	<script src="../js/modernizr.js"></script>
	<script src="../js/classie.js"></script>
	<script src="../js/uiMorphingButton_fixed.js"></script>
	<script src="../js/login.js"></script>
	<script src="../js/loginregister.js"></script>
	<script type="text/javascript" src="../js/cart.js"></script>
<script>
	$(".commodity_news_bar_ul li .commodity_news_list_show").click(function () {
		$(".commodity_news_list").show();
		$(".pinglun").hide();
	})
	$(".commodity_news_bar_ul li .pinglun_show").click(function () {
		$(".pinglun").show();
		$(".commodity_news_list").hide();
	})
	
	$(".tc-popup-hide").click(function () {
		$("#address-div").css("display","none");
	})
	$(".address").find("li").click(function(){
		if($(this).find("input").attr("checked")==undefined){
			var status=confirm("修改地址需要重新生成订单？");
			if(status){
				
				$.post("../operation/updateAddress",{oId:$(".pay_title .pay_num").find("span").html(),riId:$(this).find("input").val()},function(data){
					if(data.status!=200){
						var status1=confirm("订单已过期，是否重新生成订单？");
						if(status1){
							window.location.reload();
						}
						status=false;
					}
				});
				if(status){
					$(".address").find("li").each(function(){
						this.className ="";
						if($(this).find("input").attr("checked")!=undefined){
							$(this).find("span")[0].remove();
						}
					});
					if($(this).find("input").attr("checked")==undefined){
						$(this).prepend('<span style="color: #f40;">寄送至&nbsp;&nbsp;</span>'); 
					}
					$(this).find("input").attr("checked","checked");
					this.className ="select";
				}
			}
		}
	});
	$("#addAddress").click(function(){
		$("#address-div").css("display","block");
	})
	getRegionProvince();
	function getRegionProvince(){
		if($("#selProvince").val()==0){
			$("#yesOrNo").html("");
		}else{
			$("#yesOrNo").html('<select id="selShi"  name="code"  class="first-select"></select>');
		}
		$.post("../sax/getProvice",{code:$("#selProvince").val()},function(data){
			if(data.status==200){
				$("#selCity").html("");
				var newOption;
				for(var i in data.data){
					if(data.data[i].name!="香港"&&data.data[i].name!="澳门"&&data.data[i].name!="台湾"){
						newOption=new Option(data.data[i].name,data.data[i].code);
						$("#selCity").append(newOption);
					}
				}
				getSupportCityDataset();
			}
		})
	}
	function getSupportCityDataset(){
			$.post("../sax/getProvice",{code:$("#selCity").val()},function(data){
			if(data.status==200){
				$("#selShi").html("");
				var newOption;
				for(var i in data.data){
						newOption=new Option(data.data[i].name,data.data[i].code);
						$("#selShi").append(newOption);
				}
			}
		})
	}
	
	$("#addr_saveSubmit").click(function(){
		var address=$("#selProvince").find("option:selected").text()+" "+$("#selCity").find("option:selected").text();
		if($("#selShi")){
			address+=" "+$("#selShi").find("option:selected").text();
		}
		if( $.trim($("#addrTextarea").val())==""){
			alert("详细地址必须填写");
			return;
		}
		address+=" "+ $.trim($("#addrTextarea").val());//地址
		
		var zipCode=$.trim($(".item").find("input[name=zipCode]").val());//邮编
		var riName=$.trim($(".item").find("input[name=riName]").val());//用户名
		if(riName==""){
			alert("收货人必须填写");
			return;
		} 
		var phone=$.trim($(".item").find("input[name=phone]").val());
		var tel=$.trim($(".item").find("input[name=tel]").val());
		if(phone==""&&tel==""){
			alert("手机号码或者电话号码必须填写一个");
			return;
		}
		if(phone!=""){
			phone=$("#selPhone").find("option:selected").text()+phone;
		}else{
			tel=$("#selTel").find("option:selected").text()+tel;
		}
		var riPhone=$.trim(phone+" "+tel);//联系方式
		$.post("../operation/addAddress",{riName:riName,riAddress:address,riPhone:riPhone,riZipCode:zipCode},function(data){
			if(data.status==200){
				window.location.reload();
			}else{
				alert("新增地址失败");
			}
		})
	})
</script>
</body></html>